﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AccessKeyHighlighterControl;

namespace SampleWebsite.Controls
{
    public partial class AccessKeyHighlighterOptions : System.Web.UI.UserControl
    {
        private AccessKeyHighlighterControl.AccessKeyHighlighter _accessKeyHighlighterInstance;
        public AccessKeyHighlighterControl.AccessKeyHighlighter AccessKeyHighlighterInstance
        {
            set
            {
                _accessKeyHighlighterInstance = value;
                txtPopupButtonOffsetX.Text = _accessKeyHighlighterInstance.PopupButtonOffsetX.ToString();
                txtPopupButtonOffsetY.Text = _accessKeyHighlighterInstance.PopupButtonOffsetY.ToString();
                txtPopupLabelOffsetX.Text = _accessKeyHighlighterInstance.PopupLabelOffsetX.ToString();
                txtPopupLabelOffsetY.Text = _accessKeyHighlighterInstance.PopupLabelOffsetY.ToString();
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnOptions_Click(object sender, EventArgs e)
        {
            if (Page.IsValid && _accessKeyHighlighterInstance != null)
            {
                _accessKeyHighlighterInstance.HighlightMode = (AccessKeyHighlightMode)Enum.Parse(typeof(AccessKeyHighlightMode), ddlHighlightMode.SelectedValue);
                //_accessKeyHighlighterInstance.AccessKeyTag = (HtmlTextWriterTag)Enum.Parse(typeof(HtmlTextWriterTag), ddlAccessKeyTag.SelectedValue);
                _accessKeyHighlighterInstance.PopupButtonOffsetX = !String.IsNullOrEmpty(txtPopupButtonOffsetX.Text) ? Convert.ToInt32(txtPopupButtonOffsetX.Text) : _accessKeyHighlighterInstance.PopupButtonOffsetX;
                _accessKeyHighlighterInstance.PopupButtonOffsetY = !String.IsNullOrEmpty(txtPopupButtonOffsetY.Text) ? Convert.ToInt32(txtPopupButtonOffsetY.Text) : _accessKeyHighlighterInstance.PopupButtonOffsetY;
                _accessKeyHighlighterInstance.PopupLabelOffsetX = !String.IsNullOrEmpty(txtPopupLabelOffsetX.Text) ? Convert.ToInt32(txtPopupLabelOffsetX.Text) : _accessKeyHighlighterInstance.PopupLabelOffsetX;
                _accessKeyHighlighterInstance.PopupLabelOffsetY = !String.IsNullOrEmpty(txtPopupLabelOffsetY.Text) ? Convert.ToInt32(txtPopupLabelOffsetY.Text) : _accessKeyHighlighterInstance.PopupLabelOffsetY;
            }
        }
    }
}